import collections
class Solution(object):
    def countCharacters(self, words, chars):
        """
        :type words: List[str]
        :type chars: str
        :rtype: int
        """
        w = [collections.Counter(word) for word in words]
        c = collections.Counter(chars)
        t = 0
        for i in range(len(words)):
            if not w[i] - c:
                t += len(words[i])
        return t